package helper

import (
	"os"
	"path/filepath"
	"runtime"
)

// ExecuteBasePath 可执行文件及目录
func ExecuteBasePath(paths ...string) string {
	path := ""
	if len(paths) > 0 {
		path = paths[0]
	}

	return filepath.Dir(os.Args[0]) + path
}

// CodeBasePath 代码基目录
func CodeBasePath(paths ...string) string {
	_, file, _, ok := runtime.Caller(0)
	if !ok {
		panic("获取代码路径失败")
	}

	path := ""
	if len(paths) > 0 {
		path = paths[0]
	}

	return filepath.Dir(filepath.Dir(filepath.Dir(filepath.Dir(file)))) + path
}
